<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="js/ajax.js"></script>
</head>

<body>
    <button>发送请求</button>
    <script>
        const btnObj = document.querySelector("button");
        /* 
            服务端开放了跨域访问，设置了如下头信息。
            Access-Control-Allow-Origin": "*",

            请求头信息：
            Accept-Encoding: gzip, deflate
            Accept-Language: zh-CN,zh;q=0.9
            Cache-Control: no-cache
            Host: 120.78.190.136:8088
            Origin: null
            Pragma: no-cache
            Proxy-Connection: keep-alive
            User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36            


            响应头信息：
            Access-Control-Allow-Origin: *
            Connection: keep-alive
            Content-Length: 11
            Content-Type: text/plain;charset=UTF-8
            Date: Mon, 05 Dec 2022 08:15:33 GMT
            Keep-Alive: timeout=4
            Proxy-Connection: keep-alive
            Vary: Origin
            Vary: Access-Control-Request-Method
            Vary: Access-Control-Request-Headers
        */
        btnObj.onclick = function () {
            ajax({
                url: 'http://120.78.190.136:8088/spboot/cross',
                success: function (data) {
                    console.log("访问成功!");
                    console.log(data);
                }
            })
        }
    </script>
</body>

</html>